package com.example.service.impl;

import com.example.entity.GameInfo;
import com.example.mapper.GameInfoMapper;
import com.example.service.GameInfoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class GameInfoServiceImpl implements GameInfoService {

    @Autowired
    GameInfoMapper gameInfoMapper;


    @Override
    public void add(GameInfo gameInfo) {
        gameInfoMapper.insert(gameInfo);
    }

    @Override
    public void deleteById(Integer id) {
        gameInfoMapper.deleteById(id);
    }

    @Override
    public void updateById(GameInfo gameInfo) {
        gameInfoMapper.updateById(gameInfo);
    }

    @Override
    public PageInfo<GameInfo> selectPage(Integer pageNum, Integer pageSize, Integer gameId, String gameName, String gameType) {
        PageHelper.startPage(pageNum,pageSize);
        List<GameInfo> gameList = gameInfoMapper.selectAll(gameId,gameName,gameType);
        return PageInfo.of(gameList);
    }


}
